﻿
using System;
using Newtonsoft.Json;
using UnityEngine;

namespace province
{
public class ProvinceData{

    [JsonProperty("id")]
    public int Id { get; set; }
    [JsonProperty("r")] public float r { get; set; }
    [JsonProperty("g")] public float g { get; set; }
    [JsonProperty("b")] public float b { get; set; }
    [JsonProperty("owner")]
    public String owner { get; set; }
    [JsonProperty("name")]
    public String name { get; set; }
    
    [JsonIgnore]
    public Color kMapColor { get; set; }
    [JsonIgnore]
    public Color kShowColor;
    
    public ProvinceData(int id, Color mapColor)
    {
        Id = id;
        kMapColor = mapColor;
        kShowColor = mapColor;
        kShowColor.a = 0;
    }

    public ProvinceData()
    {
    }

    public ProvinceData(int id, Color mapColor, string owner)
    {
        Id = id;
        kMapColor = mapColor;
        this.owner = owner;
    }

    public void InitFromJson()
    {
        this.kMapColor = new Color(r/255f, g/255f, b/255f);

        owner = owner.ToUpper();
    }
    public void InitFromBytes()
    {
        this.kMapColor = new Color(r/255f, g/255f, b/255f);
        owner = owner.ToUpper();
    }

}
}